<?php
	class Model_ajax extends CI_Model{
		protected $_table = "tbl_votes";
		protected $_track = "tbl_votes_track";
		protected $_comment = "tbl_comment";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function getship($id){
			$query = $this->db->query("SELECT `sheep_id` FROM `".$this->_table."` WHERE `sheep_id` = '$id'");
			//$query = $this->db->query("SELECT `sheep_id` FROM `tbl_votes_track` WHERE `sheep_id` = '$id' AND `votet_ip` = '$ip' AND (`votet_date` >= NOW() - INTERVAL 7 DAY) LIMIT 1");
			return $query->num_rows();
		}
		public function checksh($id,$ip){
			$query = $this->db->query("SELECT `sheep_id` FROM `tbl_votes_track` WHERE `sheep_id` = '$id' AND `votet_ip` = '$ip' AND (`votet_date` >= NOW() - INTERVAL 7 DAY) LIMIT 1");
			return $query->num_rows();
		}
		public function checkmail($email,$id){
			$query = $this->db->query("SELECT `sheep_id` FROM `tbl_votes_track` WHERE `votet_email` = '$email' AND `sheep_id` = '$id'");
			return $query->num_rows();
		}
		public function add($data){
			$this->db->insert($this->_table,$data);
		}
		public function add_comment($data){
			$this->db->insert($this->_comment,$data);
		}
		public function query($sql){
			$this->db->query($sql);
		}
	}